package servlet.comm;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import factory.comm.TitleDAOFactory;
import vo.comm.Title;

public class UpdateTitleServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
    public UpdateTitleServlet() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String after_titlename=request.getParameter("after_titlename");
		String titleid=request.getParameter("titleid");
		Title title=new Title();
		title.setTitlename(after_titlename);
		title.setTitleid(titleid);
		response.setContentType("text/html; charset=UTF-8");

		try {
			if(TitleDAOFactory.getITitleDAOInstance().doUpdate(title)){
				response.sendRedirect("title/update_success.jsp");
			}
			else{
				response.sendRedirect("title/update_failure.jsp");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}	
	}

}
